/**
 * @properties={typeid:35,uuid:"F6478A7A-1E9A-4BA7-8AEE-312F60F51591",variableType:-4}
 */
var fMap = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"2F4BF355-B092-412A-98B9-FE7901D62ED3",variableType:8}
 */
var fTotal = null;


/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"469DDF37-7F68-4DD7-AD47-8CD10A578653"}
 */
function onShow(firstShow, event) {
	fTotal = forms.reserva_4.fTotal
	imagenGmaps()
	enviarMail(mail)
}


/**
 * @properties={typeid:24,uuid:"E487AD4A-5928-452D-8145-8D1D90E3BA96"}
 */
function imagenGmaps() {
	var $direccion = ghotel_to_hoteles.direccion + ',' + ghotel_to_hoteles.hoteles_to_ciudades.descripcion + ',' + ghotel_to_hoteles.hoteles_to_paises.descripcion
	$direccion = $direccion.replace(' ','+')
	while ($direccion.indexOf(' ') != -1)
	{
		$direccion = $direccion.replace(' ','+')
	}
	var $url = 'http://maps.googleapis.com/maps/api/staticmap?center='+$direccion+'&zoom=13&size=185x125&maptype=roadmap'+
	'&markers=color:red%7Clabel:H%7C'+$direccion+'&sensor=false'
	elements.lbl_map.imageURL = $url
}
/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"EDEE281C-633E-40DD-84BA-58DE42B05A58"}
 */
function imprimir(event) {
	controller.showPrintPreview(true)
}

/**
 * @param {String} destino
 * 
 * @properties={typeid:24,uuid:"0C3CED25-1997-46C5-ABD3-2F1E11FEB85D"}
 */
function enviarMail(destino) {
	
	var $Asunto 	= 'Voucher para su reserva';
	var $Mensaje 	= 'Sr/a. '+reservas_to_reserva_detalle.nombre + ' ' + reservas_to_reserva_detalle.apellido +' ¡Gracias por habernos elegido!';

	var $temp = plugins.file.createTempFile('reserva_'+codigo_interno, '.pdf');
	controller.print(true,false,plugins.pdf_output.getPDFPrinter($temp.getAbsolutePath()))
	var $adj = new Array()
	$adj.push(plugins.mail.createBinaryAttachment( 'reserva_'+codigo_interno, plugins.file.readFile($temp.getAbsolutePath())))

	globals.enviarMail(destino, $Asunto, $Mensaje, $adj, false)
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"B7F57B0C-2580-43F7-A156-2D19FB68654E"}
 */
function iraReservaMail(event) {
	var $win = application.createWindow('ENVIAR_MAIL',JSWindow.MODAL_DIALOG)
	$win.undecorated = true
	
	forms.reserva_5_mail.controller.show($win)
}
